var app = getApp()
Page({
  data: {
    arraydetail: [],
    author: 'Lotus'
  },
  getlist: function () {
    var that = this;
    var service = 'Collections.get';
    var ctype = 2;
    wx.request({
      method: 'POST',
      url: app.globalData.APIURL,
      data: { service: service, openId: app.globalData.openId, ctype: ctype },
      header: { 'Content-Type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        //console.log("success:" + res.data.data);
        if (!res.data.data.code) {
          that.setData({ arraydetail: res.data.data.list })
        } else {
          that.setData({ arraydetail: [] })
        }
      },
      fail: function (res) {
        //console.log("fail:" + res);
      },
    })
  },
  del: function (e) {
    var that = this;
    var service = 'Collections.delete';
    var pId = e.target.dataset.id;
    var ctype = 2;
    console.log("pId:" + pId);
    console.log("ctype:" + ctype);
    wx.request({
      method: 'POST',
      url: app.globalData.APIURL,
      data: { service: service, openId: app.globalData.openId, pId: pId, ctype: ctype },
      header: { 'Content-Type': 'application/x-www-form-urlencoded' },
      success: function (res) {
        console.log("success:" + res.data.data);
        that.getlist();
      },
      fail: function (res) {
        //console.log("fail:" + res);
      },
    })
  },
  onLoad: function (options) {
    var that = this;
    if (options.fromInviteCode) {
      app.globalData.fromInviteCode=options.fromInviteCode;
    }
    app.appstart();
    that.getlist();
  }
})